<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/page/common/commonConfig.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>

<head>
    <title>用户模板</title>
    <script src="<%=basePath%>component/layout.js"></script>
    <script src="<%=basePath%>component/toolbar.js"></script>
    <script src="<%=basePath%>component/grid.js"></script>
    <script type="text/javascript" src="<%=basePath%>dwrsystem/engine.js"></script>
	<script type="text/javascript" src="<%=basePath%>dwrsystem/interface/userService.js"></script>
	
	<script type="text/javascript">
	var mygrid;
	var userId;
	var dhxLayout = createLayoutNormal('1C');
	
	var dhxGrid = {
		initDataTable : function () {
		    mygrid.setHeader("序号,模板描述,模板地址,默认");
		    mygrid.setInitWidths("50,150,*,50");
		    mygrid.setColAlign("right,left,left,center");
		    mygrid.setColSorting("int,str,str,str");
		    mygrid.setColTypes("ro,ro,ro,ro");
		    mygrid.init();
		    setSkin(mygrid);
		    mygrid.loadXML('<%=basePath%>system-display/DisplayAction!displayGrid.action?userId=' + userId);
		},
		saveDisplay : function (){
			var rowId = mygrid.getSelectedId();
			if(rowId){
				layoutProgressOn(dhxLayout);
				userService.updateTUserByPK({userMainId:userId,frameModelId:rowId},function(){
					parent.parent.parent.notifyCreater('保存成功');
					layoutProgressOff(dhxLayout);
				});
			}
			else {
				parent.parent.parent.notifyWarn('请选择操作项');
				layoutProgressOff(dhxLayout);
			}
		}
	};
	
	function configLayout(){
		var a = dhxLayout.cells('a');
		a.hideHeader();
		a.setText('主页面');
		a.fixSize(true, true);
		mygrid = createGridFromLayoutCell(a);
		if(power.getPower() != '' && power.getPowerUpdate())
			createToolbarFromDHXLayoutCell(a,function(toolbar){
			    toolbar.addText("info", 1, "操作:");
			    toolbar.addSeparator("sep1", 2);
			    if(power.getPowerUpdate()) toolbar.addButton("update", 4, "保存", "save.gif", "save_dis.gif");
			    toolbar.attachEvent("onClick", function(id) {
			    	if(id == 'update'){
			    		dhxGrid.saveDisplay();
			    	}
			    });
			});
	}

	$(function (){
		userId = '${param.userMainId}';
		configLayout();
	 	dhxGrid.initDataTable();
	});
	</script>
</head>

<body>
</body>

</html>
